package com.bobi.tfca.ui.adapter

import androidx.fragment.app.Fragment
import androidx.viewpager2.adapter.FragmentStateAdapter

typealias MemManHandleFragment = () -> Fragment
open class MemManagePagerAdapter (fragment: Fragment): FragmentStateAdapter(fragment){

    private val fragments = mutableListOf<MemManHandleFragment>()

    override fun getItemCount(): Int = fragments.size

    override fun createFragment(position: Int): Fragment = fragments[position].invoke()

    fun add(fragment: MemManHandleFragment): MemManagePagerAdapter{
        fragments.add(fragment)
        return this
    }

    fun add(fragmentList: List<MemManHandleFragment>): MemManagePagerAdapter{
        fragments.addAll(fragmentList)
        return this
    }
}